package cn.qingsec.controller;

import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
import cn.qingsec.service.Oauth2ServerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Sa-OAuth2 Client端 控制器
 * @author kong
 */
@RestController
@RequestMapping
public class SaOAuthClientController {
	@Autowired
	private Oauth2ServerService oauth2ServerService;

	// 相关参数配置
	private String clientId = "1001";								// 应用id
	private String clientSecret = "aaaa-bbbb-cccc-dddd-eeee";		// 应用秘钥
	private String serverUrl = "http://sa-oauth-server.com:8001";	// 服务端接口

	@GetMapping("isLogin")
	public SaResult isLogin(){
		return oauth2ServerService.isLogin();
	}
	@GetMapping("getLoginUser")
	public SaResult getLoginUser(){
		return oauth2ServerService.getLoginUser();
	}
	@GetMapping("checkLogin")
	public SaResult checkLogin(){
		return oauth2ServerService.checkLogin();
	}
	@GetMapping("checkPermission")
	public SaResult checkPermission(){
		return oauth2ServerService.checkPermission();
	}


	@GetMapping("test")
	public SaResult test(){
		return SaResult.ok("是否登录：" + StpUtil.isLogin());
	}
}
